package ru.myrtle.umf.impl;

import java.util.*;
import ru.myrtle.umf.*;
import ru.myrtle.umf.util.*;

public class UOperationImpl extends UObjectImpl implements UOperation {

    protected static final boolean PROVIDED_DEFAULT = Boolean.FALSE;
    protected static final String NAME_DEFAULT = null;
    protected static final String DESCRIPTION_DEFAULT = null;
    protected static final boolean MANY_DEFAULT = Boolean.FALSE;
    protected static final boolean ORDERED_DEFAULT = Boolean.FALSE;
    protected static final boolean UNIQUE_DEFAULT = Boolean.FALSE;

    public UOperationImpl() {
    }

    @Override
    public UClass uClass() {
        return UModel.UOPERATION;
    }
    
    private boolean _provided_ = PROVIDED_DEFAULT;

    @Override
    public final boolean isProvided() {
        return _provided_;
    }

    @Override
    public final boolean isSetProvided() {
        return _provided_ != PROVIDED_DEFAULT;
    }

    @Override
    public final void setProvided(boolean _provided_) {
        this._provided_ = _provided_;
    }

    @Override
    public final void unsetProvided() {
        _provided_ = PROVIDED_DEFAULT;
    }

    private UClassifier _type_;

    @Override
    public final UClassifier getType() {
        return _type_;
    }

    @Override
    public final boolean isSetType() {
        return _type_ != null;
    }

    private void setTypeImpl(UClassifier _type_) {
        this._type_ = _type_;
    }

    @Override
    public final void setType(UClassifier _type_) {
        if (this._type_ != _type_) {
                                                                    setTypeImpl(_type_);
                                                                }
    }
    
    @Override
    public final void unsetType() {
        setTypeImpl(null);
    }

    private UList<UParameter> _parameters_;

    @Override
    public final UList<UParameter> getParameters() {
        if (_parameters_ == null) {
            _parameters_ = new UObjectContainmentWithInverseList<UParameter>(this, UModel.UOPERATION__PARAMETERS, UModel.UPARAMETER__OPERATION);
        }
        return _parameters_;
    }

    @Override
    public final boolean isSetParameters() {
        return _parameters_ != null && !_parameters_.isEmpty();
    }

    @Override
    public void setParameters(UList<UParameter> _parameters_) {
        getParameters().clear();
        getParameters().addAll(_parameters_);
    }

    @Override
    public void unsetParameters() {
        if (_parameters_ != null) {
            _parameters_.clear();
        }
    }

    private UList<UClass> _exceptions_;

    @Override
    public final UList<UClass> getExceptions() {
        if (_exceptions_ == null) {
            _exceptions_ = new UObjectList<UClass>();
        }
        return _exceptions_;
    }

    @Override
    public final boolean isSetExceptions() {
        return _exceptions_ != null && !_exceptions_.isEmpty();
    }

    @Override
    public void setExceptions(UList<UClass> _exceptions_) {
        getExceptions().clear();
        getExceptions().addAll(_exceptions_);
    }

    @Override
    public void unsetExceptions() {
        if (_exceptions_ != null) {
            _exceptions_.clear();
        }
    }

    private UClassifier _containingClassifier_;

    @Override
    public final UClassifier getContainingClassifier() {
        return _containingClassifier_;
    }

    @Override
    public final boolean isSetContainingClassifier() {
        return _containingClassifier_ != null;
    }

    private void setContainingClassifierImpl(UClassifier _containingClassifier_) {
        this._containingClassifier_ = _containingClassifier_;
    }

    private String _name_ = NAME_DEFAULT;

    @Override
    public final String getName() {
        return _name_;
    }

    @Override
    public final boolean isSetName() {
        return _name_ != NAME_DEFAULT;
    }

    @Override
    public final void setName(String _name_) {
        this._name_ = _name_;
    }

    @Override
    public final void unsetName() {
        _name_ = NAME_DEFAULT;
    }

    private String _description_ = DESCRIPTION_DEFAULT;

    @Override
    public final String getDescription() {
        return _description_;
    }

    @Override
    public final boolean isSetDescription() {
        return _description_ != DESCRIPTION_DEFAULT;
    }

    @Override
    public final void setDescription(String _description_) {
        this._description_ = _description_;
    }

    @Override
    public final void unsetDescription() {
        _description_ = DESCRIPTION_DEFAULT;
    }

    private UList<UAnnotation> _annotations_;

    @Override
    public final UList<UAnnotation> getAnnotations() {
        if (_annotations_ == null) {
            _annotations_ = new UObjectContainmentList<UAnnotation>(this, UModel.UELEMENT__ANNOTATIONS);
        }
        return _annotations_;
    }

    @Override
    public final boolean isSetAnnotations() {
        return _annotations_ != null && !_annotations_.isEmpty();
    }

    @Override
    public void setAnnotations(UList<UAnnotation> _annotations_) {
        getAnnotations().clear();
        getAnnotations().addAll(_annotations_);
    }

    @Override
    public void unsetAnnotations() {
        if (_annotations_ != null) {
            _annotations_.clear();
        }
    }

    private boolean _many_ = MANY_DEFAULT;

    @Override
    public final boolean isMany() {
        return _many_;
    }

    @Override
    public final boolean isSetMany() {
        return _many_ != MANY_DEFAULT;
    }

    @Override
    public final void setMany(boolean _many_) {
        this._many_ = _many_;
    }

    @Override
    public final void unsetMany() {
        _many_ = MANY_DEFAULT;
    }

    private boolean _ordered_ = ORDERED_DEFAULT;

    @Override
    public final boolean isOrdered() {
        return _ordered_;
    }

    @Override
    public final boolean isSetOrdered() {
        return _ordered_ != ORDERED_DEFAULT;
    }

    @Override
    public final void setOrdered(boolean _ordered_) {
        this._ordered_ = _ordered_;
    }

    @Override
    public final void unsetOrdered() {
        _ordered_ = ORDERED_DEFAULT;
    }

    private boolean _unique_ = UNIQUE_DEFAULT;

    @Override
    public final boolean isUnique() {
        return _unique_;
    }

    @Override
    public final boolean isSetUnique() {
        return _unique_ != UNIQUE_DEFAULT;
    }

    @Override
    public final void setUnique(boolean _unique_) {
        this._unique_ = _unique_;
    }

    @Override
    public final void unsetUnique() {
        _unique_ = UNIQUE_DEFAULT;
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public Object uGet(UFeature feature) {
        if (feature == UModel.UOPERATION__PROVIDED) {
            return isProvided();
        }
        if (feature == UModel.UOPERATION__TYPE) {
            return getType();
        }
        if (feature == UModel.UOPERATION__PARAMETERS) {
            return getParameters();
        }
        if (feature == UModel.UOPERATION__EXCEPTIONS) {
            return getExceptions();
        }
        if (feature == UModel.UOPERATION__CONTAINING_CLASSIFIER) {
            return getContainingClassifier();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return getName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return getDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return getAnnotations();
        }
        if (feature == UModel.UMULTIPLICITY__MANY) {
            return isMany();
        }
        if (feature == UModel.UMULTIPLICITY__ORDERED) {
            return isOrdered();
        }
        if (feature == UModel.UMULTIPLICITY__UNIQUE) {
            return isUnique();
        }

        return super.uGet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public boolean uIsSet(UFeature feature) {
        if (feature == UModel.UOPERATION__PROVIDED) {
            return isSetProvided();
        }
        if (feature == UModel.UOPERATION__TYPE) {
            return isSetType();
        }
        if (feature == UModel.UOPERATION__PARAMETERS) {
            return isSetParameters();
        }
        if (feature == UModel.UOPERATION__EXCEPTIONS) {
            return isSetExceptions();
        }
        if (feature == UModel.UOPERATION__CONTAINING_CLASSIFIER) {
            return isSetContainingClassifier();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return isSetName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return isSetDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return isSetAnnotations();
        }
        if (feature == UModel.UMULTIPLICITY__MANY) {
            return isSetMany();
        }
        if (feature == UModel.UMULTIPLICITY__ORDERED) {
            return isSetOrdered();
        }
        if (feature == UModel.UMULTIPLICITY__UNIQUE) {
            return isSetUnique();
        }

        return super.uIsSet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uSet(UFeature feature, Object value) {
        if (feature == UModel.UOPERATION__PROVIDED) {
            setProvided(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UOPERATION__TYPE) {
            setType((UClassifier) value);
            return;
        }
        if (feature == UModel.UOPERATION__PARAMETERS) {
            setParameters((UList<UParameter>) value);
            return;
        }
        if (feature == UModel.UOPERATION__EXCEPTIONS) {
            setExceptions((UList<UClass>) value);
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            setName((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            setDescription((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            setAnnotations((UList<UAnnotation>) value);
            return;
        }
        if (feature == UModel.UMULTIPLICITY__MANY) {
            setMany(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UMULTIPLICITY__ORDERED) {
            setOrdered(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UMULTIPLICITY__UNIQUE) {
            setUnique(((Boolean) value).booleanValue());
            return;
        }

        super.uSet(feature, value);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uUnset(UFeature feature) {
        if (feature == UModel.UOPERATION__PROVIDED) {
            unsetProvided();
            return;
        }
        if (feature == UModel.UOPERATION__TYPE) {
            unsetType();
            return;
        }
        if (feature == UModel.UOPERATION__PARAMETERS) {
            unsetParameters();
            return;
        }
        if (feature == UModel.UOPERATION__EXCEPTIONS) {
            unsetExceptions();
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            unsetName();
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            unsetDescription();
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            unsetAnnotations();
            return;
        }
        if (feature == UModel.UMULTIPLICITY__MANY) {
            unsetMany();
            return;
        }
        if (feature == UModel.UMULTIPLICITY__ORDERED) {
            unsetOrdered();
            return;
        }
        if (feature == UModel.UMULTIPLICITY__UNIQUE) {
            unsetUnique();
            return;
        }

        super.uUnset(feature);
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseAdd(UObject otherEnd, UReference reference) {
        if (reference == UModel.UOPERATION__PARAMETERS) {
            ((UObjectList<UParameter>) getParameters()).basicAdd((UParameter) otherEnd);
            return;
        }
        if (reference == UModel.UOPERATION__CONTAINING_CLASSIFIER) {
            setContainingClassifierImpl((UClassifier) otherEnd);
            return;
        }
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseRemove(UObject otherEnd, UReference reference) {
        if (reference == UModel.UOPERATION__PARAMETERS) {
            ((UObjectList<UParameter>) getParameters()).basicRemove((UParameter) otherEnd);
            return;
        }
        if (reference == UModel.UOPERATION__CONTAINING_CLASSIFIER) {
            setContainingClassifierImpl(null);
            return;
        }
    }


    @Override
    public String toString() {
        StringBuffer result = new StringBuffer();

        result.append("UOperation");
        result.append(" (");
        result.append("provided: ");
        result.append(_provided_);
        result.append(", ");
        result.append("name: ");
        result.append(_name_);
        result.append(", ");
        result.append("description: ");
        result.append(_description_);
        result.append(", ");
        result.append("many: ");
        result.append(_many_);
        result.append(", ");
        result.append("ordered: ");
        result.append(_ordered_);
        result.append(", ");
        result.append("unique: ");
        result.append(_unique_);
        result.append(')');

        return result.toString();
    }
}




